<?php
/**
 * asignacion_empleados
 *
 * asignacion_empleados.php
 * @author Hector Ruiz
 * @version 1.0
 * @copyright Hector Ruiz, 13 October, 2011
 * @package default
 **/

class Asignacion_empleado extends CI_Controller {

    public function __construct() {
        parent::__construct();

        $this->load->model("menu_model");
        $this->load->model("equipos_model");

        //Only logged in users are alowed to access this controller
        if($this->session->userdata('logged_in') == FALSE) redirect('login');
    }

    function index() {
        $data = $this->menu_model->general("Equipo asignado a empleados");
        $data['site_name'] = "Inventario Asignado a Empleados";
        $data['app_menu'] = $this->menu_model->return_link_menu('asignaciones');
        $data['content_html'] = $this->dashboard();
        $js = '
        
                $(document).ready( function () {
                $("#example").dataTable( {
                    "aaSorting":[[1, "asc"]],
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers",
                    "sDom": \'<"H"Tfr>t<"F"ip>\',
                    "oTableTools": {
                    "sSwfPath": "'.$this->config->item('swf_path').'copy_cvs_xls_pdf.swf",
                    "aButtons": [
                        {
                            "sExtends": "copy",
                            "mColumns": [0, 1, 2, 3]
                        },
                        {
                            "sExtends": "csv",
                            "mColumns": [0, 1, 2, 3]
                        },
                        {
                            "sExtends": "xls",
                            "mColumns": [0, 1, 2, 3]
                        },
                        {
                            "sExtends": "pdf",
                            "mColumns": [0, 1, 2, 3]
                        }
                    ]
                    }
                } );
            } );
            
            ';
        $data['js'] = $js;
        
        $this->load->view('template', $data);
    }

    function dashboard() {
        $images_path = $this->config->item('images_path');
        $html = "";
        $html.= "<table id='example' width='100%' class='ui-widget-header'>";
        $html.= "<thead>";
        $html.= "<tr>";
        $html.= "<th>NOMBRE</th>";
        $html.= "<th>DEPARTAMENTO</th>";
        $html.= "<th>PUESTO</th>";
        $html.= "<th>EXTENSION</th>";
        $html.= "<th>ASIGNAR</th>";
        $html.= "<th>RETIRAR</th>";
        $html.= "<th>EQUIPO ASIGNADO</th>";
        $html.= "</tr>";
        $html.= "</thead>";
        $sort = array('departamento, apellido_paterno, apellido_materno, nombre_1');
        $evalues = $this->equipos_model->get_list('empleados', "", $sort);
        if(!empty($evalues)) {
            $html.= "<tbody class='ui-widget-container'>";
            foreach($evalues as $k=>$v) {
                $nombre = $evalues[$k]['nombre_1'];
                if(!empty($evalues[$k]['nombre_2'])) {
                    $nombre .= ' '.$evalues[$k]['nombre_2'];
                }
                $nombre.= ' '.$evalues[$k]['apellido_paterno'].' '.$evalues[$k]['apellido_materno'];
                $departamentos_id = $evalues[$k]['departamento'];
                $d_vals = $this->equipos_model->read('catalogo_departamentos','id', $departamentos_id);
                $departamento_desc = $d_vals[0]['departamento'];
                $puesto_id = $evalues[$k]['puesto'];
                $p_vals = $this->equipos_model->read('catalogo_puestos', 'id', $puesto_id);
                $puesto_desc = $p_vals[0]['puesto'];
                $extension = $evalues[$k]['extension'];
                $usuario_red = $evalues[$k]['usuario_red'];
                $url = anchor('asignacion_empleado/verify_record/'.$usuario_red,'<strong>Asignar Equipo</strong>');
                $url1 = anchor('asignacion_empleado/verify_record_2_retrieve/'.$usuario_red,'<strong>Retirar Equipo</strong>');
                $url2 = anchor_popup('asignacion_empleado/asignar/'.$usuario_red,'<strong>Equipo Asignado</strong>');
                $html.= "<tr>";
                $html.= "<td>".$nombre."</td>";
                $html.= "<td>".$departamento_desc."</td>";
                $html.= "<td>".$puesto_desc."</td>";
                $html.= "<td>".$extension."</td>";
                $html.= "<td>".$url."</td>";
                $html.= "<td>".$url1."</td>";
                $html.= "<td>".$url2."</td>";
                $html.= "</tr>";
            }
            $html.= "</tbody>";
        }
        $html.= "</table>";

        return $html;
    }

    function verify_record($usuario_red, $id = "") {
        $where = array('usuarios_id' => $usuario_red);
        $where_2 = array('usuario_red' => $usuario_red);
        $qq = $this->equipos_model->read_w('e_asignados', $where);
        $evalues = $this->equipos_model->get_list('empleados',$where_2, 'usuario_red');
        if(!empty($evalues)) {
            foreach($evalues as $k=>$v) {
                $nombre_completo = $evalues[$k]['nombre_1'].' '.$evalues[$k]['nombre_2'].' '.$evalues[$k]['apellido_paterno'].' '.$evalues[$k]['apellido_materno'];
            }
        }
        $ids = array();
        if($qq->num_rows() > 0) {
            foreach($qq->result() as $rr) {
                $ids[] = $rr->id;
            }
        }
        if(!empty($ids)) {
            $images_path = $this->config->item('images_path');
            $data = $this->menu_model->general("Equipo Asignado a Empleado");
            $data['site_name'] = "Inventario Asignado a Empleados";
            $data['app_menu'] = $this->menu_model->return_link_menu('asignacion_empleado');
            
            $html = "";
            $html.= "<div>";
            foreach($ids as $k=>$v) {
                $form = "";
                //mostrar Usuario objeto de asignacion
                $html = "<table width='30%' class='ui-widget-header'>";
                $html .= "<thead>";
                $html .= "<tr>";
                $html .= "<th>Usuario de Red</th>";
                $html .= "<th>Nombre</th>";
                $html .= "</thead>";
                $html .= "<tbody class='ui-widget-container'>";
                $html .= "<td>".$usuario_red."</td>";
                $html .= "<td>".$nombre_completo."</td>";
                $html .= "</tbody>";
                $html .= "</table>";
                $html .= "<br>";
                //Creacion de la tabla de equipo asignado al usuario
                $html .= "<table id='example' width='100%' class='ui-widget-header'>";
                $html .= "<thead>";
                $html .= "<tr>";
                $html .= "<th>NO.</th>";
                $html .= "<th>FECHA DE REGISTRO</th>";
                $html .= "<th>DEPARTAMENTO</th>";
                $html .= "<th>OPCION</th>";
                $html .= "</tr>";
                $html .= "</thead>";
                $html .= "<tbody class='ui-widget-container'>";
                $e_values = $this->equipos_model->get_list('e_asignados', $where, 'id');
                if(!empty($e_values)) {
                    foreach ($e_values as $k => $v) {
                        $num = $k+1;
                        $html .= "<tr align = 'center'>";
                        $html .= "<td>".$num."</td>";
                        $html .= "<td>".$this->equipos_model->format_date($e_values[$k]['fecha_registro'],1)."</td>";
                        $d_values = $this->equipos_model->read('catalogo_departamentos', 'id', $e_values[$k]['departamentos_id']);
                        $html .= "<td>".$d_values[0]['departamento']."</td>";
                        $html .= "<td>".anchor('asignacion_empleado/asignar/'.$usuario_red.'/'.$e_values[$k]['id'], '<img src="'.$images_path.'edit.gif" border="0" width="22" height="22" />');
                        $html .= "</tr>";
                   }
                }

                $html .= "</tbody>";
                $html .= "</table>";
                $html .= "<br>";

            }
            //crear uno nuevo
            $html.= form_open('asignacion_empleado/asignar/'.$usuario_red);
            $html.= form_submit('nueva_asignacion', 'Nueva Asignacion');
            $html.= form_close();
            $data['content_html'] = $html;
            $js = '
            
                    $(document).ready( function () {
                    $("#example").dataTable( {
                        "aaSorting":[[0, "asc"]],
                        "bJQueryUI": true,
                        "sPaginationType": "full_numbers",
                        "sDom": \'<"H"Tfr>t<"F"ip>\',
                        "oTableTools": {
                        "sSwfPath": "'.$this->config->item('swf_path').'copy_cvs_xls_pdf.swf",
                        "aButtons": [
                            {
                                "sExtends": "copy",
                                "mColumns": [0, 1, 2]
                            },
                            {
                                "sExtends": "csv",
                                "mColumns": [0, 1, 2]
                            },
                            {
                                "sExtends": "xls",
                                "mColumns": [0, 1, 2]
                            },
                            {
                                "sExtends": "pdf",
                                "mColumns": [0, 1, 2]
                            }
                        ]
                        }
                    } );
                } );
                
                ';
            $data['js'] = $js;
            $this->load->view('template',$data);
        } else {
            redirect('asignacion_empleado/asignar/'.$usuario_red);
        }
    }

    function asignar($usuario_red, $id = "") {
        $evalues = $this->equipos_model->read('empleados', 'usuario_red', $usuario_red);
        $nombre = $evalues[0]['nombre_1'];
        if(!empty($evalues[0]['nombre_2'])) {
            $nombre.= ' '.$evalues[0]['nombre_2'];
        }
        $nombre.= ' '.$evalues[0]['apellido_paterno'].' '.$evalues[0]['apellido_materno'];
        $data = $this->menu_model->general("Asignar equipo empleado");
        $data['site_name'] = "Inventario Asignado a Empleados";
        $data['app_menu'] = $this->menu_model->return_link_menu('asignacion_empleado');
        $js_date = 'onKeyDown="javascript:return dFilter (event.keyCode, this, \'##-##-####\');"';

        $form_path = "asignacion_empleado/asignar/".$usuario_red.'/'.$id;
        $path = "asignacion_empleado/index";
        $table = "e_asignados";
        $id_name = "id";

        $fields['id'] = "ID:";
        $fields['usuarios_id'] = "Usuario:";
        $fields['fecha_registro'] = "<font color='red'>Fecha de Registro</font>:";
        $fields['departamentos_id'] = "Departamento:";
        $fields['computadoras_id'] = "Computadora:";
        $fields['monitores_id'] = "Monitore:";
        $fields['teclados_id'] = "Teclado:";
        $fields['ratones_id'] = "Raton:";
        $fields['impresoras_id'] = "Impresora:";
        $fields['escaners_id'] = "Escaner:";
        $fields['telefonos_id'] = "Telefono:";
        $fields['switches_id'] = "Switches:";
        $fields['routers_id'] = "Routers:";
        $fields['cablemodems_id'] = "Cable Modem:";
        $fields['emtas_id'] = "EMTA:";
        $fields['transcievers_id'] = "Transciever:";
        $fields['access_points_id'] = "Access Point:";
        $fields['accesorios_id'] = "Accesorios:";
        $fields['sistema_operativo'] = "Sistema Operativo:";
        $fields['version_office'] = "Version de Office:";

        $this->form_validation->set_rules('fecha_registro', $fields['fecha_registro'], 'required');

        if($this->form_validation->run() == FALSE) {
            $new = 1;
            $where = array('id_asignacion' => 0);
            $values = array();
            foreach($fields as $k=>$v) {
                $values[0][$k] = "";
            }
            $where_c = array('id' => $id, 'usuarios_id' => $usuario_red);
            $qq = $this->equipos_model->read_w('e_asignados',$where_c);
            if($qq->num_rows() > 0) {
                $new = 0;
                $where = "";
                foreach($qq->result() as $row) {
                    foreach($fields as $k=>$v) {
                        $values[0][$k] = $row->$k;
                    }
                }
            }
            $departamentos_id_options = array();
            $w_condition = array('disponibilidad' => 1);
            $dvals = $this->equipos_model->get_list('catalogo_departamentos',$w_condition,'departamento');
            if(!empty($dvals)) {
                foreach($dvals as $k=>$v) {
                    $departamentos_id_options[$dvals[$k]['id']] = $dvals[$k]['departamento'];
                }
            }
            $computadoras_id_options = array(0 => '----------');
            $cvals = $this->equipos_model->get_list('computadoras', $where, 'modelo');
            if(!empty($cvals)) {
                foreach($cvals as $k=>$v) {
                    $computadoras_id_options[$cvals[$k]['numero_serie']] = "S/N: ".$cvals[$k]['numero_serie']." ".$cvals[$k]['modelo'];
                }
            }
            $monitores_id_options = array(0 => '----------');
            $mvals = $this->equipos_model->get_list('monitores', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $monitores_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $teclados_id_options = array(0 => '----------');
            $mvals = $this->equipos_model->get_list('teclados', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $teclados_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $ratones_id_options = array(0 => '----------');
            $mvals = $this->equipos_model->get_list('ratones', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $ratones_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $impresoras_id_options = array(0 => '----------');
            $mvals = $this->equipos_model->get_list('impresoras', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $impresoras_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $escaners_id_options = array(0 => '---------');
            $mvals = $this->equipos_model->get_list('escaners', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $escaners_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $telefonos_id_options = array(0 => '---------');
            $mvals = $this->equipos_model->get_list('telefonos', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $telefonos_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $switches_id_options = array(0 => '---------');
            $mvals = $this->equipos_model->get_list('switches', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $switches_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $routers_id_options = array(0 => '---------');
            $mvals = $this->equipos_model->get_list('routers', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $routers_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $cablemodems_id_options = array(0 => '---------');
            $mvals = $this->equipos_model->get_list('cablemodems', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $cablemodems_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $emtas_id_options = array(0 => '---------');
            $mvals = $this->equipos_model->get_list('emtas', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $emtas_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $transcievers_id_options = array(0 => '---------');
            $mvals = $this->equipos_model->get_list('transcievers', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $transcievers_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $access_points_id_options = array(0 => '---------');
            $mvals = $this->equipos_model->get_list('access_points', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $access_points_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }
            $accesorios_id_options = array(0 => '---------');
            $mvals = $this->equipos_model->get_list('accesorios', $where, 'modelo');
            if(!empty($mvals)) {
                foreach($mvals as $k=>$v) {
                    $accesorios_id_options[$mvals[$k]['numero_serie']] = "[".$mvals[$k]['numero_serie']."] ".$mvals[$k]['modelo'];
                }
            }

            $form = "";
            $html = "<table>";
            $html .= "<thead>";
            $html .= "<tr bgcolor='#CEE3F6'>";
            $html .= "</thead>";
            $html .= "<tbody>";
            $html .= "<tbody>";
            $html .= "</table>";

            $form .= "<div>";
            $form .= "<p>Campos en <span class='required'>Rojo</span> son requiridos!</p>";
            $form .= "</div>";

            if(validation_errors()) {
                $form .= "<div>";
                $form .= "<p>".str_replace('*', '', validation_errors())."</p>";
                $form .= "</div>";
            }

            $form .= form_open($form_path);
            $form .= form_hidden($id_name, $id);
            $form .= form_hidden('usuarios_id', $usuario_red);

            $form .= "<div>";
            $form .= form_label($fields["usuarios_id"],"usuarios_id")."[".$usuario_red."]  ".$nombre;
            $form .= "<br/>";
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["fecha_registro"],"fecha_registro");
            $form .= "<br/>";
            $form .= form_input(array('name' => 'fecha_registro', 'id' => 'fecha_registro', 'size' => 10, 'class' => 'datepicker'), set_value('fecha_registro', $values[0]['fecha_registro']), $js_date);
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["departamentos_id"],"departamentos_id");
            $form .= "<br/>";
            $form .= form_dropdown("departamentos_id", $departamentos_id_options, set_value("departamentos_id", $values[0]["departamentos_id"]),'id="departamentos_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["computadoras_id"],"computadoras_id");
            $form .= "<br/>";
            $form .= form_dropdown("computadoras_id", $computadoras_id_options, set_value("computadoras_id", $values[0]["computadoras_id"]),'id="computadoras_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["monitores_id"],"monitores_id");
            $form .= "<br/>";
            $form .= form_dropdown("monitores_id", $monitores_id_options, set_value("monitores_id", $values[0]["monitores_id"]),'id="monitores_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["teclados_id"],"teclados_id");
            $form .= "<br/>";
            $form .= form_dropdown("teclados_id", $teclados_id_options, set_value("teclados_id", $values[0]["teclados_id"]),'id="teclados_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["ratones_id"],"ratones_id");
            $form .= "<br/>";
            $form .= form_dropdown("ratones_id", $ratones_id_options, set_value("ratones_id", $values[0]["ratones_id"]),'id="ratones_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["impresoras_id"],"impresoras_id");
            $form .= "<br/>";
            $form .= form_dropdown("impresoras_id", $impresoras_id_options, set_value("impresoras_id", $values[0]["impresoras_id"]),'id="impresoras_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["escaners_id"],"escaners_id");
            $form .= "<br/>";
            $form .= form_dropdown("escaners_id", $escaners_id_options, set_value("escaners_id", $values[0]["escaners_id"]),'id="escaners_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["telefonos_id"],"telefonos_id");
            $form .= "<br/>";
            $form .= form_dropdown("telefonos_id", $telefonos_id_options, set_value("telefonos_id", $values[0]["telefonos_id"]),'id="telefonos_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["switches_id"],"switches_id");
            $form .= "<br/>";
            $form .= form_dropdown("switches_id", $switches_id_options, set_value("switches_id", $values[0]["switches_id"]),'id="switches_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["routers_id"],"routers_id");
            $form .= "<br/>";
            $form .= form_dropdown("routers_id", $routers_id_options, set_value("routers_id", $values[0]["routers_id"]),'id="routers_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["cablemodems_id"],"cablemodems_id");
            $form .= "<br/>";
            $form .= form_dropdown("cablemodems_id", $cablemodems_id_options, set_value("cablemodems_id", $values[0]["cablemodems_id"]),'id="cablemodems_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["emtas_id"],"emtas_id");
            $form .= "<br/>";
            $form .= form_dropdown("emtas_id", $emtas_id_options, set_value("emtas_id", $values[0]["emtas_id"]),'id="emtas_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["transcievers_id"],"transcievers_id");
            $form .= "<br/>";
            $form .= form_dropdown("transcievers_id", $transcievers_id_options, set_value("transcievers_id", $values[0]["transcievers_id"]),'id="transcievers_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["access_points_id"],"access_points_id");
            $form .= "<br/>";
            $form .= form_dropdown("access_points_id", $access_points_id_options, set_value("access_points_id", $values[0]["access_points_id"]),'id="access_points_id"');
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["sistema_operativo"],"sistema_operativo");
            $form .= "<br/>";
            $form .= form_input(array( "name" => "sistema_operativo", "id" => "sistema_operativo", "size" => "35"), set_value("sistema_operativo", $values[0]["sistema_operativo"]));
            $form .= "</div>";

            $form .= "<div>";
            $form .= form_label($fields["version_office"],"version_office");
            $form .= "<br/>";
            $form .= form_input(array( "name" => "version_office", "id" => "version_office", "size" => "10"), set_value("version_office", $values[0]["version_office"]));
            $form .= "</div>";

            if($new) {
                $form .= "<br/>";
                $form .= "<div>";
                $form .= form_submit('submit', 'Submit') . nbs(2) . form_reset('reset', 'Reset');
                $form .= "</div>";
            }

            $form .= form_close();
            $data['content_html'] = $form;
            $this->load->view('template',$data);
        } else {
            $id = $this->input->post($id_name);
            $usuario_red = $this->input->post('usuario_red');
            $data = array();
            foreach($fields as $k=>$v) {
                $value = $this->input->post($k);
                $data[$k] = $value;
            }
            $this->equipos_model->save_asignacion($table, $id_name, $id, $usuario_red, $data);
            redirect($path);
        }
    }
    function verify_record_2_retrieve($usuario_red, $id = "") {
        $where = array('usuarios_id' => $usuario_red);
        $where_2 = array('usuario_red' => $usuario_red);
        $qq = $this->equipos_model->read_w('e_asignados', $where);
        $evalues = $this->equipos_model->get_list('empleados',$where_2, 'usuario_red');
        if(!empty($evalues)) {
            foreach($evalues as $k=>$v) {
                $nombre_completo = $evalues[$k]['nombre_1'].' '.$evalues[$k]['nombre_2'].' '.$evalues[$k]['apellido_paterno'].' '.$evalues[$k]['apellido_materno'];
            }
        }
        $ids = array();
        if($qq->num_rows() > 0) {
            foreach($qq->result() as $rr) {
                $ids[] = $rr->id;
            }
        }
        if(!empty($ids)) {
            $data = $this->menu_model->general("Equipo Asignado a Empleado");
            $data['site_name'] = "Inventario Asignado a Empleados";
            $data['app_menu'] = $this->menu_model->return_link_menu('asignacion_empleado');
            $html = "";
            $html.= "<div>";
            foreach($ids as $k=>$v) {
                $form = "";
                //mostrar Usuario objeto de asignacion
                $html = "<table border = 1>";
                $html .= "<thead>";
                $html .= "<tr bgcolor='#CEE3F6'>";
                $html .= "<th>Usuario de Red</th>";
                $html .= "<th>Nombre</th>";
                $html .= "</thead>";
                $html .= "<tbody>";
                $html .= "<td>".$usuario_red."</td>";
                $html .= "<td>".$nombre_completo."</td>";
                $html .= "</tbody>";
                $html .= "</table>";
                $html .= "<br>";
                //Creacion de la tabla de equipo asignado al usuario
                $html .= "<table border =1>";
                $html .= "<thead>";
                $html .= "<tr bgcolor='#CEE3F6'>";
                $html .= "<th>NO.</th>";
                $html .= "<th>FECHA DE REGISTRO</th>";
                $html .= "<th>DEPARTAMENTO</th>";
                $html .= "<th>COMPUTADORAS</th>";
                $html .= "<th>MONITORES</th>";
                $html .= "<th>TECLADOS</th>";
                $html .= "<th>RATONES</th>";
                $html .= "<th>IMPRESORAS</th>";
                $html .= "<th>ESCANERS</th>";
                $html .= "<th>TELEFONOS</th>";
                $html .= "<th>SWITCHES</th>";
                $html .= "<th>ROUTERS</th>";
                $html .= "<th>CABLEMODEMS</th>";
                $html .= "<th>EMTA's</th>";
                $html .= "<th>TRANSCIEVERS</th>";
                $html .= "<th>ACCESS POINTS</th>";
                $html .= "<th>ACCESORIOS</th>";
                $html .= "<th>S.O.</th>";
                $html .= "<th>OFFICE</th>";
                $html .= "<th>OPCION</th>";
                $html .= "</thead>";
                $html .= "<tbody>";
                $e_values = $this->equipos_model->get_list('e_asignados', $where, 'id');
                if(!empty($e_values)) {
                    foreach ($e_values as $k => $v) {
                        $num = $k+1;
                        $html .= "<tr align = 'center'>";
                        $html .= "<th>".$num."</th>";
                        $html .= "<td>".$e_values[$k]['fecha_registro']."</td>";
                        $d_values = $this->equipos_model->read('catalogo_departamentos', 'id', $e_values[$k]['departamentos_id']);
                        $html .= "<td>".$d_values[0]['departamento']."</td>";
                        if($e_values[$k]['computadoras_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['computadoras_id']."</td>";
                        }
                        if($e_values[$k]['monitores_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['monitores_id']."</td>";
                        }
                        if($e_values[$k]['teclados_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['teclados_id']."</td>";
                        }
                        if($e_values[$k]['ratones_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['ratones_id']."</td>";
                        }
                        if($e_values[$k]['impresoras_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['impresoras_id']."</td>";
                        }
                        if($e_values[$k]['escaners_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['escaners_id']."</td>";
                        }
                        if($e_values[$k]['telefonos_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['telefonos_id']."</td>";
                        }
                        if($e_values[$k]['switches_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['switches_id']."</td>";
                        }
                        if($e_values[$k]['routers_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['routers_id']."</td>";
                        }
                        if($e_values[$k]['cablemodems_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['cablemodems_id']."</td>";
                        }
                        if($e_values[$k]['emtas_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['emtas_id']."</td>";
                        }
                        if($e_values[$k]['transcievers_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['transcievers_id']."</td>";
                        }
                        if($e_values[$k]['access_points_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['access_points_id']."</td>";
                        }
                        if($e_values[$k]['accesorios_id'] == "0") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['accesorios_id']."</td>";
                        }
                        if($e_values[$k]['sistema_operativo'] == "") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['sistema_operativo']."</td>";
                        }
                        if($e_values[$k]['version_office'] == "") {
                            $html.="<td bgcolor='gray'></td>";
                        }else {
                            $html .= "<td>".$e_values[$k]['version_office']."</td>";
                        }

                        $html .= "<td bgcolor='#CEE3F6'>".anchor('asignacion_empleado/retirar/'.$usuario_red.'/'.$e_values[$k]['id'], "Retirar");
                        $html .= "</tr>";
                   }
                }

                $html .= "</tbody>";
                $html .= "</table>";
                $html .= "<br>";

            }
            $data['content_html'] = $html;
            $this->load->view('template',$data);
        } else {
            redirect('asignacion_empleado/asignar/'.$usuario_red);
        }
    }
    function retirar($usuario_red, $id = "") {
        
    }
}
/* end of file */
